//
//  TJTabBarViewController.swift
//  WeiBo
//
//  Created by TanJian on 15/12/5.
//  Copyright © 2015年 Joshpell. All rights reserved.
//

import UIKit

class TJTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = TJTabBar()
        
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(TJHomeTableViewController(), title: "首页", imgName: "tabbar_home")
    
        addChildViewController(TJMessageTableViewController(), title: "消息中心", imgName: "tabbar_message_center")
        
        addChildViewController(TJDiscoveryTableViewController(), title: "发现", imgName: "tabbar_discover")
        
        addChildViewController(TJProfileTableViewController(), title: "我", imgName: "tabbar_profile")
        

    }

    
    //创建每个tabbar相应的controller
    func  addChildViewController(childController: UIViewController, title:String, imgName:String) {
        
        //tabbar的题目设置
        childController.title = title
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: .Selected)
        
        childController.tabBarItem.image = UIImage(named: imgName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        


        
        addChildViewController(TJNavigationViewController(rootViewController: childController))
        
        
        
    }



}
